﻿using System.Windows;
using System.Windows.Controls;

namespace Views
{
    /// <summary>
    /// SearchBoxPanel.xaml 的交互逻辑
    /// </summary>
    public partial class SearchBoxPanel : UserControl
    {
        public SearchBoxPanel()
        {
            InitializeComponent();
        }

        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Text.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(SearchBoxPanel), new PropertyMetadata(string.Empty));

        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox textBox = (TextBox)sender;
            if (textBox.Text.Length == 0)
            {
                this.SearchText.Text = "\xe60f";
            }
            else
            {
                this.SearchText.Text = "\xe69f";
            }
        }

        private void Clear_Click(object sender, RoutedEventArgs e)
        {
            this.SearchTextbox.Text = string.Empty;
        }
    }
}